﻿@{
    Layout = null;
}

<link href="~/libs/layui-v2.9.21/layui-v2.9.21/layui/css/layui.css" rel="stylesheet" />

<form class="layui-form layui-form-pane" action="" lay-filter="editForm">
    <input type="hidden" name="id" />

    <div class="layui-form-item">
        <label class="layui-form-label">仓库名称</label>
        <div class="layui-input-block">
            <input type="text" name="warehouse" lay - verify="required" placeholder="请输入仓库名称" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">储位类型</label>
        <div class="layui-input-block">
            <input type="text" name="locationType" lay - verify="required" placeholder="请输入储位类型" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">储位编码</label>
        <div class="layui-input-block">
            <input type="text" name="location" lay - verify="required" placeholder="请输入储位编码" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">所属客户</label>
        <div class="layui-input-block">
            <input type="text" name="customer" lay - verify="required" placeholder="请输入所属客户" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">最大体积</label>
        <div class="layui-input-block">
            <input type="number" step="0.01" name="maxVolume" lay - verify="required" placeholder="请输入最大体积"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">上架次序</label>
        <div class="layui-input-block">
            <input type="text" name="shelvingSequence" lay - verify="required" placeholder="请输入上架次序" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">长度(单位：CM)</label>
        <div class="layui-input-block">
            <input type="number" name="lengthCM" lay - verify="required" placeholder="请输入长度" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">宽度(单位：CM)</label>
        <div class="layui-input-block">
            <input type="number" name="widthCM" lay - verify="required" placeholder="请输入宽度" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">高度(单位：CM)</label>
        <div class="layui-input-block">
            <input type="number" name="heightCM" lay - verify="required" placeholder="请输入高度" autocomplete="off"
                   class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">最大托盘</label>
        <div class="layui-input-block">
            <input type="number" name="maxPallet" lay - verify="required" placeholder="请输入最大托盘" autocomplete="off"
                   class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="saveBtn">保存</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>

<script src="~/libs/layui-v2.9.21/layui-v2.9.21/layui/layui.js"></script>
<script src="~/libs/jquery/jquery.js"></script>

<script>
    layui.use(['form'], function(){
        var form = layui.form;
        var $ = layui.$;
        var layer = layui.layer;

        // 加载数据方法
        window.loadData = function(id) {
            $.get('/OtherInbound/GetOtherInboundById', { id: id }, function(res){
                console.log('获取到的数据:', res);
                if(res.code === "0"){
                    var formData = {
                        id: res.data.result.id,
                        warehouse: res.data.result.warehouse,
                        locationType: res.data.result.locationType,
                        location: res.data.result.location,
                        customer: res.data.result.customer,
                        maxVolume: res.data.result.maxVolume,
                        shelvingSequence: res.data.result.shelvingSequence,
                        lengthCM: res.data.result.lengthCM,
                        widthCM: res.data.result.widthCM,
                        heightCM: res.data.result.heightCM,
                        maxPallet: res.data.result.maxPallet,

                    };
                    form.val('editForm', formData);
                    form.render();
                } else {
                    layer.msg('获取数据失败');
                }
            });
        }

        // 监听提交
        form.on('submit(saveBtn)', function(data){
            $.ajax({
                url: '/OtherInbound/UpdateOtherInbound',
                type: 'post',
                data: data.field,
                success: function(res){
                    console.log('保存结果:', res);
                    if(res > 0){
                        alert('保存成功');
                        // 刷新父页面表格
                        parent.layui.table.reload('Table');
                        // 关闭弹窗
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    }else{
                        alert('保存失败');
                    }
                }
            });
            return false;
        });

         // var unit = function(){
         //        $.ajax({
         //            url: "/CommodityDetail/GetDictItemById",
         //            type: "get",
         //            dataType: "json",
         //            data: { id: 1 },
         //            success: function (res) {
         //                console.log(res)
         //                var data = res;
         //                var html = "";
         //                for (var i = 0; i < data.length; i++) {
         //                    html += "<option value='" + data[i].sortId + "'>" + data[i].dictItemName + "</option>";
         //                }
         //                $("#unit").html(html);
         //                form.render('select');
         //            }
         //        });
         //   }

         //   unit();


    });
</script> 